<?php
class Uji_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }
	
	function get_id_jawaban_responden($id_responden)
	{
		$this->db->select('*');
		$this->db->from('"responden_kuesioner"');
		$this->db->where('fk_id_responden',$id_responden);
		$result = $this->db->get();
		return $result->result_array();
	}
	
	function delete_responden($id_responden)
	{
		$this->db->where('id_responden', $id_responden);
		$this->db->delete('responden');
	}
	
	function delete_jawaban_responden($id_jawaban)
	{
		$this->db->where('id_jawaban_responden', $id_jawaban);
		$this->db->delete('jawaban_responden');
	}
	
	function tanda_reliabel($id_kuesioner, $status)
	{
		$data = array(
			'reliabilitas' => $status
		);
		$this->db->where('id_kuesioner', $id_kuesioner);
		$this->db->update('kuesioner', $data);
	}
	
	function tanda_valid($id_kuesioner, $status)
	{
		$data = array(
			'validitas' => $status
		);
		$this->db->where('id_kuesioner', $id_kuesioner);
		$this->db->update('kuesioner', $data);
	}
	
	function insert_file_csv($nama, $deskripsi, $file_csv, $id_user, $publish_penelitian, $publish_metodologi, $publish_data)
	{
		$data = array(
			'nama_kuesioner' => $nama,
			'deskripsi' => $deskripsi,
			'status' => 1,
			'file_csv' => $file_csv,
			'fk_id_user' => $id_user,
			'publish' => $publish_penelitian,
			'publish_metodologi' => $publish_metodologi,
			'publish_data' => $publish_data
		);
		$this->db->insert('kuesioner', $data);
		return $this->db->insert_id();
	}
	
	function update_proposal($id_kuesioner, $file_prop)
	{
		$data = array(
			'file_proposal' => $file_prop
		);
		$this->db->where('id_kuesioner', $id_kuesioner);
		$this->db->update('kuesioner', $data);
	}
	
	function get_data_csv($id)
	{
		$this->db->select('*');
		$this->db->from('"kuesioner"');
		$this->db->where('id_kuesioner', $id);
		$result = $this->db->get();
		return $result->result_array();
	}
	
	function insert_variabel_csv($variabel, $id, $jenis_pert)
	{
		$data = array(
			'pertanyaan' => $variabel,
			'fk_id_kuesioner' => $id,
			'fk_id_jenis_pertanyaan' => $jenis_pert
		);
		$this->db->insert('pertanyaan', $data);
		return $this->db->insert_id();
	}
	
	function insert_responden($responden)
	{
		$data = array(
			'responden' => $responden
		);
		$this->db->insert('responden', $data);
		return $this->db->insert_id();
	}
	
	function insert_jawaban_responden($jawaban)
	{
		$data = array(
			'jawaban' => $jawaban
		);
		$this->db->insert('jawaban_responden', $data);
		return $this->db->insert_id();
	}
	
	function insert_responden_kuesioner($id_responden, $id_pert, $id_jawaban_responden)
	{
		$data = array(
			'fk_id_responden' => $id_responden,
			'fk_id_pertanyaan' => $id_pert,
			'fk_id_jawaban_responden' => $id_jawaban_responden
		);
		$this->db->insert('responden_kuesioner', $data);
	}
	
	function nilai_t($df)
	{
		$this->db->select('*');
		$this->db->from('"tabel_t"');
		$this->db->where('id_tabel_t',$df);
		$result = $this->db->get();
		return $result->result_array();
	}
	
	function get_keterangan($id)
	{
		$this->db->select('*');
		$this->db->from('"kuesioner"');
		$this->db->where('id_kuesioner', $id);
		$result = $this->db->get();
		return $result->result_array();
	}
	
	function update_keterangan($id_kues, $pp, $pm, $pd)
	{
		$data = array(
			'publish' => $pp,
			'publish_metodologi' => $pm,
			'publish_data' => $pd
		);
		$this->db->where('id_kuesioner', $id_kues);
		$this->db->update('"kuesioner"', $data);
	}
	
	function get_nilai_tabel_normal($z)
	{
		$this->db->select('*');
		$this->db->from('tabel_distribusi_normal');
		$this->db->where('z', $z);
		$result = $this->db->get();
		return $result->result_array();
	}
	
	function get_nilai_tabel_lilifors($jml_sampel)
	{
		$this->db->select('*');
		$this->db->from('tabel_nilai_kritis_L');
		$this->db->where('jumlah_sampel', $jml_sampel);
		$result = $this->db->get();
		return $result->result_array();
	}
}
?>